layui.config({
	base : "/dhjdglxt/modules/util/"//自定义加载的模块
}).use(['form','layer','jquery','layedit','laydate','laypage','table','commUtil','element'],function(){
	var form = layui.form,
		layer = parent.layer === undefined ? layui.layer : parent.layer,
		laypage = layui.laypage,
		layedit = layui.layedit,
		laydate = layui.laydate,
		$ = layui.jquery;
		var table = layui.table;
		var commUtil = layui.commUtil;
		var element = layui.element;
		
		laydate.render({
		    elem: '#ghFbdate',
		    trigger: 'click',
		    type:'date'
		});
		//监听提交
		form.on('submit(formSubmit)', function(data){
			var recId='0';
			data.field.ghStatus = 1;
			if(data.field.recId!=''){
				recId=data.field.recId;
			}
			$.ajax({
		        type: "PUT",
		        url: basePath+'/service/jdghgl/jdghgl/'+recId,
		        data: data.field,
		        async:false,
		        dataType: "json",
		        success: function(data){
		        	if(data.code=='0'){
		        		layer.msg("操作成功", {icon: 1});
		        		 parent.location.reload();	
		    		} else {
		    			layer.msg("操作失败", {icon: 0});
		    		}
		        }
		    });
		});
		
		//监听保存
		form.on('submit(saveSubmit)', function(data){
			var recId='0';
			data.field.ghStatus = 0;
			if(data.field.recId!=''){
				recId=data.field.recId;
			}
			$.ajax({
		        type: "PUT",
		        url: basePath+'/service/jdghgl/jdghgl/'+recId,
		        data: data.field,
		        async:false,
		        dataType: "json",
		        success: function(data){
		        	if(data.code=='0'){
		        		layer.msg("操作成功", {icon: 1});
		        		 parent.location.reload();	
		    		} else {
		    			layer.msg("操作失败", {icon: 0});
		    		}
		        }
		    });
		});
	})
